package com.uvnos4j.matilda.system.controller;

import com.uvnos4j.matilda.commons.utils.ResponseUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 文件 Controller
 * <p>
 * Description:文件 Controller
 * </p>
 *
 * @author Guo.wl
 * @version v1.0.0
 * @since 2020-08-29 23:05:48
 */
@Controller
@RequestMapping("/file")
public class FileController {

    /**
     * 下载文件。<br/>
     * 注解ResponseBody 解决：getOutputStream() has already been called for this response
     *
     * @param fileName 文件名称
     * @param filePath 文件路径
     */
    @ResponseBody
    @PostMapping("/download")
    public void download(String fileName, String filePath) {
        ResponseUtil.download(filePath, fileName);
    }

}